<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自查案件调整</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-disabled, .layui-disabled:hover {
            color: #000000 !important;
            cursor: not-allowed !important;
        }

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="panel panel-default operation" hidden>
                        <div class="panel-heading title"></div>
                        <div class="layui-tab">
                            <ul class="layui-tab-title">
                                <li class="layui-this">办理</li>
                                <li>流程</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-card-body">
                                        <form class="layui-form" action="" lay-filter="info">
                                            <input name="_tabKey" id="_tabKey" hidden>
                                            <input name="_jcajxxuuid" id="_jcajxxuuid" hidden>
                                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                                                <legend>案件信息</legend>
                                            </fieldset>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">案件名称</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="ajmc" name="ajmc"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                                <label class="layui-form-label">检查项目</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="jcxm" name="jcxm"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">检查人</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="jcry" name="jcry"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">纳税人名称</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="nsrmc" name="nsrmc"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                                <label class="layui-form-label">纳税人识别号</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="nsrsbh" name="nsrsbh"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                            </div>

                                            <fieldset class="layui-elem-field layui-field-title" id="bottomLine"
                                                      style="margin-top: 10px;"></fieldset>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button type="submit" class="layui-btn" id="debugtaxorg"
                                                            onclick="return false" lay-submit lay-filter="debugtaxorg">调整检查科科室
                                                    </button>
                                                    <button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                                        <legend>办理流程</legend>
                                    </fieldset>
                                    <div id="activityRecordDiv"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab table_div">
                        <ul class="layui-tab-title">
                            <li class="layui-this" id="grdb">待调整检查科室</li>
                            <li id="gryb">已调整检查科室</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--待调整检查科室-->
                            <div class="layui-tab-item layui-show">
                                <form id="searchForm0">
                                    <div class="layui-form-item">
                                        <div class="layui-input-inline">
                                            <label for="jcaybh0"></label>
                                            <input type="text" id="jcaybh0" class="layui-input" autocomplete="off"
                                                   placeholder="请输入稽查案源编号">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="nsrsbh0"></label>
                                            <input type="text" id="nsrsbh0" class="layui-input" autocomplete="off"
                                                   placeholder="请输入纳税人识别号">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="nsrmc0"></label>
                                            <input type="text" id="nsrmc0" class="layui-input" autocomplete="off"
                                                   placeholder="请输入纳税人名称">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="startTime0"></label>
                                            <input type="text" readonly class="layui-input" id="startTime0" placeholder="录入时间起">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="endTime0"></label>
                                            <input type="text" readonly class="layui-input" id="endTime0" placeholder="录入时间止">
                                        </div>
                                        <div class="layui-input-inline">
                                            <button class="layui-btn" type="button" onclick="searchZcajtz()">查询</button>
                                            <button class="layui-btn" type="button" id="resetBtn0">重置</button>
                                        </div>
                                        <div class="layui-input-inline">
                                            <button class="layui-btn" type="button" id="exportBtn">导出</button>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <span style="color: red;font-size: 18px;margin-left: 10px">当前案源数据时间范围：2023年1月1日-至今</span>
                                    </div>
                                </form>
                                <table class="layui-table" id="grdbShowTable" lay-filter="grdbShowTable"></table>
                            </div>
                            <!--已调整检查科室-->
                            <div class="layui-tab-item">
                                <form id="searchForm1">
                                    <div class="layui-form-item" >
                                        <div class="layui-input-inline">
                                            <label for="jcaybh1"></label>
                                            <input type="text" id="jcaybh1" class="layui-input" autocomplete="off"
                                                   placeholder="请输入稽查案源编号">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="nsrsbh1"></label>
                                            <input type="text" id="nsrsbh1" class="layui-input" autocomplete="off"
                                                   placeholder="请输入纳税人识别号">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="nsrmc1"></label>
                                            <input type="text" id="nsrmc1" class="layui-input" autocomplete="off"
                                                   placeholder="请输入纳税人名称">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="startTime1"></label>
                                            <input type="text" readonly class="layui-input" id="startTime1" placeholder="录入时间起">
                                        </div>
                                        <div class="layui-input-inline">
                                            <label for="endTime1"></label>
                                            <input type="text" readonly class="layui-input" id="endTime1" placeholder="录入时间止">
                                        </div>
                                        <div class="layui-input-inline">
                                            <button class="layui-btn" type="button" onclick="searchZcajytz()">查询</button>
                                            <button class="layui-btn" type="button" id="resetBtn1">重置</button>
                                        </div>
                                        <div class="layui-input-inline">
                                            <button class="layui-btn" type="button" id="exportBtn1">导出</button>
                                        </div>
                                    </div>
                                    <table class="layui-table" id="grybShowTable" lay-filter="grybShowTable"></table>
                                </form>
                            </div>

                        </div>
                    </div>
                    <!--调整弹出层-->
                    <div id="debugtaxorgDiv" class="demo-transfer" style="display: none">
                        <div class="layui-form">
                            <div class="layui-form-item" style="margin-top: 5px">
                                <label class="layui-form-label" style="">选择科室</label>
                                <div class="layui-input-block">
                                    <label for="debugtaxorgSelect"></label>
                                    <select lay-search="" name="debugtaxorgSelect" lay-filter="debugtaxorgSelect" id="debugtaxorgSelect">
                                        <option value="">请选择科室</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/html" id="grdbTool">
    <a class="layui-btn layui-btn-xs" lay-event="view">调整</a>
</script>
<!-- 表格容器 -->
<table id="swjgTable" lay-filter="swjgTable"></table>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="javascript">
    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var grdbTableIns;
    var grybTableIns;
    var jgdmTableIns;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var maxlength = 500;
    var debugtaxorg = "";
    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        // 个人待办
        grdbTableIns = table.render({
            elem: '#grdbShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/inspect/queryZcayxx' //数据接口
            ,
            method: 'POST',
            where: {
                zcajlx: "0"
            },
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                {align: 'center', width: 230, field: 'jcajxxuuid', title: '检查UUID', sort: true, hide: true},
                {align: 'center', width: 220, field: 'jcaybh', title: '检查案件编号', sort: true},
                {align: 'center', width: 200, field: 'nsrsbh', title: '纳税人识别号', sort: true},
                {align: 'center', width: 300, field: 'nsrmc', title: '纳税人名称', sort: true},
                {align: 'center', width: 280, field: 'jsks', title: '金三科室', sort: true},
                {align: 'center', width: 280, field: 'tzhks', title: '调整后科室', sort: true},
                {align: 'center', width: 150, field: 'swjcayztmc', title: '案件状态', sort: true},
                {
                    align: 'center', width: 150, field: 'lrrq', title: '立案时间', sort: true, templet: function (d) {
                        // 格式化日期为 'yyyy-MM-dd'
                        return layui.util.toDateString(d.lrrq, 'yyyy-MM-dd');
                    }
                },
                {fixed: 'right', align: 'center', width: 75, toolbar: "#grdbTool", title: '操作'}
            ]],
            toolbar: '#grdbToolbar'
        });
        // 个人已办
        grybTableIns = table.render({
            elem: '#grybShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/inspect/queryZcayxx' //数据接口
            ,
            method: 'POST',
            where: {
                zcajlx: "1"
            },
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                // {align: 'center', field: 'jcayxxuuid', title: '稽查案源信息UUID', hide: true},
                // {align: 'center', field: 'jcaybh', title: '稽查案源编号'},
                // // {align : 'center',field : 'nsrsbh', title : '纳税人识别号'},
                // {align: 'center', field: 'jczcryDm', title: '主查税务人员'},
                // {align: 'center', field: 'jcxcryDm', title: '协查税务人员'},
                // {align: 'center', field: 'content', title: '调整原因'},
                // {align: 'center', field: 'createId', title: '调整人'}
                {align: 'center', width: 230, field: 'jcajxxuuid', title: '检查UUID', sort: true, hide: true},
                {align: 'center', width: 220, field: 'jcaybh', title: '检查案件编号', sort: true},
                {align: 'center', width: 200, field: 'nsrsbh', title: '纳税人识别号', sort: true},
                {align: 'center', width: 300, field: 'nsrmc', title: '纳税人名称', sort: true},
                {align: 'center', width: 280, field: 'jsks', title: '金三科室', sort: true},
                {align: 'center', width: 280, field: 'tzhks', title: '调整后科室', sort: true},
                {align: 'center', width: 150, field: 'swjcayztmc', title: '案件状态', sort: true},
                {
                    align: 'center', width: 150, field: 'lrrq', title: '立案时间', sort: true, templet: function (d) {
                        // 格式化日期为 'yyyy-MM-dd'
                        return layui.util.toDateString(d.lrrq, 'yyyy-MM-dd');
                    }
                },
                {fixed: 'right', align: 'center', width: 75, toolbar: "#grdbTool", title: '操作'}
            ]],
            toolbar: '#grybToolbar'
        });
        // 个人待办表头工具
        table.on('grdbToolbar(grdbShowTable)', function (obj) {
            switch (obj.event) {
            }
        });
        // 个人已办表头工具
        table.on('grybToolbar(grybShowTable)', function (obj) {
            switch (obj.event) {
            }
        });
        // 列操作
        table.on('tool(grdbShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    /* lock(data); */
                    view(data, "0");
                    break;
            }
        });
        // 个人已办操作
        table.on('tool(grybShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "1");
                    break;
            }
        });
        // 返回
        $("#btn_cancel").click(function () {
            back();
            return false;
        });
        // 推送业务部门税务机关
        form.on('select(debugtaxorgSelect)', function () {
            var myselect = document.getElementById("debugtaxorgSelect");
            var index = myselect.selectedIndex; // selectedIndex代表的是你所选中项的index
            debugtaxorg = myselect.options[index].value;
        });
        // 调整检查机关
        form.on('submit(debugtaxorg)', function (data) {
            debugtaxorg = "";
            CoreUtil.sendPost("/workflow/activity/debugtaxorg", null, function (res) {
                if (res.code == '0') {
                    var value = res.data;
                    var opt = "<option value = ''>请选择调整科室</option>";
                    for (var i in value) {
                        opt += '<option value = "' + value[i].swjgDm + '">' + value[i].swjgjc + '</option>';
                    }
                    $("#debugtaxorgSelect").html(opt);
                    form.render('select'); //需要渲染一下
                } else {
                    layer.msg(res.msg);
                    return false;
                }
            });

            layer.open({
                type: 1,
                // offset : '50px',
                skin: 'layui-layer-molv',
                title: "调整检查科室",
                area: ['700px', '420px'],
                shade: 0,
                shadeClose: false,
                content: jQuery("#debugtaxorgDiv"),
                btn: ['调整检查科室', '取消'],
                yes: function (index) {
                    var jcajxxuuid = $('#_jcajxxuuid').val();
                    var mapArr = {
                        'jcajxxuuid': jcajxxuuid,
                        'debugtaxorg': debugtaxorg,
                        'content': $('#content').val(),
                    };
                    CoreUtil.sendPost("/workflow/inspect/doTzAyksry", mapArr,
                        function (res) {
                            if (res.code == '0') {
                                layer.msg("成功 调整检查科室！");
                                back();
                                return false;
                            } else {
                                layer.msg(res.msg);
                                return false;
                            }
                        });
                    layer.close(index);
                }
            });

        });
        // 查看退回原因
        form.on('submit(viewBack)', function (data) {
            var sjbh = $('#_sjbh').val();
            var clzt = data.field._clzt;
            if (CoreUtil.isEmpty(sjbh)) {
                layer.msg("sjbh没有获取到，请稍后重试!");
                return false;
            }
            if (CoreUtil.isEmpty(clzt)) {
                layer.msg("clzt没有获取到，请稍后重试!");
                return false;
            }

            viewBack(sjbh, clzt);

            layer.open({
                type: 1,
                offset: '50px',
                skin: 'layui-layer-molv',
                title: "查看退回原因",
                area: ['500px', '400px'],
                shade: 0,
                shadeClose: false,
                content: jQuery("#ckthyyDiv"),
                btn: ['确定', '取消'],
                yes: function (index) {
                    layer.close(index);
                }
            });

        });

        $("#grdb").click(function () {
            grdbSearch();
        });

        $("#gryb").click(function () {
            grybSearch();
        });

        upload.render({
            elem: '#import' //绑定元素
            , url: '/workflow/inspect/importDataAyxxJgryData?authorization=' + tokenQuery //上传接口
            , exts: 'xlsx' //限制上传文件
            , size: "20480"
            , before: function (obj) {
                layer.msg('文件上传导入中...', {
                    icon: 16,
                    shade: 0.01,
                    time: 0
                })
            }
            , done: function (res) {
                if (res.code == "0") {
                    layer.msg("导入调整数据成功！");
                } else {
                    layer.msg(res.msg);
                }
            }
            , error: function () {
                layer.msg("文件上传失败，请稍后重试！");
            }
        });

        //调整-检查科室
        table.on('tool(grdbShowTable)', function (obj) {
            openAdjustTaxOrgModal(obj);
        });
        table.on('tool(grybShowTable)', function (obj) {
            openAdjustTaxOrgModal(obj);
        });

        //待调整检查科室下拉选
        function openAdjustTaxOrgModal(obj) {
            CoreUtil.sendPost("/workflow/activity/debugtaxorg", null, function (res) {
                if (res.code == '0') {
                    let value = res.data;
                    let opt = "<option value = ''>请选择调整科室</option>";
                    for (let i in value) {
                        opt += '<option value="' + value[i].swjgDm + '|' + value[i].swjgjc + '">' + value[i].swjgjc + '</option>';
                    }
                    $("#debugtaxorgSelect").html(opt);
                    form.render('select'); //需要渲染一下
                } else {
                    layer.msg(res.msg);
                    return false;
                }
            });
            layer.open({
                type: 1,
                offset: '50px',
                skin: 'layui-layer-molv',
                title: "调整检查科室",
                area: ['700px', '420px'],
                shade: 0,
                shadeClose: false,
                content: jQuery("#debugtaxorgDiv"),
                btn: ['调整检查科室', '取消'],
                yes: function (index) {
                    // 获取选中的值
                    obj.data.selectedValue = $('#debugtaxorgSelect').val();
                    CoreUtil.sendPost("/workflow/inspect/saveZcajks", obj.data,
                        function (res) {
                            if (res.code == '0') {
                                layer.msg("成功调整检查科室！");
                                searchZcajtz();
                                searchZcajytz();
                                return false;
                            } else {
                                layer.msg(res.msg);
                                return false;
                            }
                        });
                    layer.close(index);
                }
            });
        }
    });

    //调整查询
    function searchZcajtz() {
        const lrsjqValue = $("#startTime0").val();
        const lrsjzValue = $("#endTime0").val();
        if (!lrsjqValue && lrsjzValue) {
            layer.msg('请输入录入时间起', {icon: 5, time: 1500});
            return;
        } else if (lrsjqValue && !lrsjzValue) {
            layer.msg('请输入录入时间止', {icon: 5, time: 1500});
            return;
        } else if (lrsjqValue > lrsjzValue) {
            layer.msg('录入时间起不能大于录入时间止', {icon: 5, time: 1500});
            return;
        }
        //这里以搜索为例
        grdbTableIns.reload({
            where: { //设定异步数据接口的额外参数，任意设
                jcaybh: $("#jcaybh0").val(),
                nsrsbh: $("#nsrsbh0").val(),
                nsrmc: $("#nsrmc0").val(),
                zcajlx: "0",
                lrsjq: lrsjqValue,
                lrsjz: lrsjzValue
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }

    //已调整查询
    function searchZcajytz() {
        const lrsjqValue = $("#startTime1").val();
        const lrsjzValue = $("#endTime1").val();
        if (!lrsjqValue && lrsjzValue) {
            layer.msg('请输入录入时间起', {icon: 5, time: 1500});
            return;
        } else if (lrsjqValue && !lrsjzValue) {
            layer.msg('请输入录入时间止', {icon: 5, time: 1500});
            return;
        } else if (lrsjqValue > lrsjzValue) {
            layer.msg('录入时间起不能大于录入时间止', {icon: 5, time: 1500});
            return;
        }
        grybTableIns.reload({
            where: { //设定异步数据接口的额外参数，任意设
                jcaybh: $("#jcaybh1").val(),
                nsrsbh: $("#nsrsbh1").val(),
                nsrmc: $("#nsrmc1").val(),
                zcajlx: "1",
                lasjq: lrsjqValue,
                lasjz: lrsjzValue
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }

    // 执行查询
    function gwdbSearch() {

        grdbTableIns.reload({
            where: {},

            page: {
                curr: 1
            }
        });
    };

    function downloadFile(e) {
        $(e).attr('src');
        window.open($(e).attr('src'), '_blank');
    }

    function lock(data) {
        var mapArr = {
            jcajxxuuid: data.jcajxxuuid
        };

        CoreUtil.sendPost("/workflow/activity/lock", mapArr, function (res) {
            if (res.code == '0') {
                layer.msg("受理成功，进入受理页面");
            } else {
                layer.msg(res.msg);
                return false;
            }
        });

    }

    function view(data, type) {
        $("#_tabKey").val(type);
        $("#_jcajxxuuid").val(data.jcajxxuuid);

        $(".title").html("案件编号：" + data.jcajbh);
        $("#ajmc").val(data.ajmc);
        $("#jcxm").val(data.jcxm);
        $("#nsrmc").val(data.nsrmc);
        $("#nsrsbh").val(data.nsrsbh);
        $("#jcry").val(data.jcry);

        var _fjdz = data.fjdz;
        if (!CoreUtil.isEmpty(_fjdz)) {
            $("#fjdz").val(_fjdz);
            var fjdzArr = _fjdz.split(",");
            var tmp = "<table class='layui-table'><tbody>";
            for (var i = 0; i < fjdzArr.length; i++) {
                var _fjdz = '"' + fjdzArr[i] + '"';
                var _i = i + 1;
                tmp += "<tr><td>附件" + _i + "</td><td>"
                    + "<a class='layui-btn layui-btn-xs' onclick='yjyl("
                    + _fjdz + ")'>一键预览</a>"
                    + "<a class='layui-btn layui-btn-xs' onclick='yjfz("
                    + _fjdz + ")'>一键复制</a>" + "</td></tr>";
            }
            tmp += "</tbody></table>";
            $("#fjdzDiv").html(tmp);
        } else {
            $("#fjdzDiv").html("未传附件");
        }

        // 查询办理流程
        activityRecordDiv(data.jcajxxuuid);

        if (type == "0") {
            $("#debugtaxorg").show();
        } else if (type == "1") {
            $("#debugtaxorg").hide();
        }

        var stateCode = data.stateCode;

        if (stateCode == "25") {
            $("#twoBooks").show();
        } else {
            $("#twoBooks").hide();
        }

        $(".table_div").hide();
        $(".operation").show();
    }

    function fwdSjfjlbView(_sjbh, flag) {
        // 获取 上传的附件列表
        var mapArr = {
            'sjbh': _sjbh,
        };

        CoreUtil.sendPost("/fwdSjfjlb/view", mapArr, function (res) {
            if (res.code == "0") {
                var data = res.data;
                if (!CoreUtil.isEmpty(data)) {
                    var tmp = "<table class='layui-table'><tbody>";
                    for (var i = 0; i < data.length; i++) {
                        var _fjdz = '"' + data[i].url + '"';
                        var _createId = '"' + data[i].createId + '"';
                        var _id = '"' + data[i].id + '"';
                        var _sjbh = '"' + data[i].sjbh + '"';
                        var tmpDel = "";
                        if (flag == "Y") {
                            tmpDel = "<a class='layui-btn layui-btn-xs fjDeleteId' onclick='deletefj(" + _id + "," + _createId + "," + _sjbh + ")'>删除</a>"
                        }

                        tmp += "<tr>"
                            + "<td>" + data[i].fileName + "</td>"
                            + "<td>上传时间：" + data[i].createDate + "</td>"
                            + "<td>上传人：" + data[i].createIdName + "</td>"
                            + "<td>"
                            + "<a class='layui-btn layui-btn-xs' onclick='yjyl(" + _fjdz + ")'>一键预览</a>"
                            + "<a class='layui-btn layui-btn-xs' onclick='yjfz(" + _fjdz + ")'>一键复制</a>"
                            + tmpDel
                            + "</td></tr>";
                    }
                    tmp += "</tbody></table>";
                    $("#fjdzDiv1").html(tmp);
                } else {
                    $("#fjdzDiv1").html("暂无附件");
                }
            }
        });

    }

    function texLength1(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('反馈内容字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    }

    function texLength2(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('推送原因字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    }

    function yjfz(_url) {
        var Url2 = _url;
        var oInput = document.createElement('input');
        oInput.value = Url2;
        document.body.appendChild(oInput);
        oInput.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        oInput.className = 'oInput';
        oInput.style.display = 'none';
        layer.msg('已复制成功！');
    }

    function yjyl(_url) {
        window.open(_url, '_blank');
    }

    function deletefj(_id, _createId, _sjbh) {
        // 删除附件
        var mapArr = {
            'id': _id,
            'sjbh': _sjbh,
            'createId': _createId,
            'flag': "Y",
        };

        CoreUtil.sendPost("/fwdSjfjlb/delete", mapArr, function (res) {
            if (res.code == '0') {
                layer.msg("文件删除成功！");
                fwdSjfjlbView(_sjbh, "Y");
            } else {
                layer.msg("文件删除失败，请稍后重试！");
                return false;
            }
        });
    }

    function back() {
        var _tabKey = $("#_tabKey").val();
        if (_tabKey == "0") {
            gwdbSearch();
            $("#grdb").attr("class", "layui-this");
            $("#gryb").attr("class", "");

        } else if (_tabKey == "1") {
            grdbSearch();
            $("#grdb").attr("class", "");
            $("#gryb").attr("class", "layui-this");

        } else {

        }

        $(".table_div").show();
        $(".operation").hide();
    }

    function ckthyy(sjbh, clzt) {
        // 获取意见
        var mapArr = {
            'sjbh': sjbh,
            'sjzt': clzt,
        };

        CoreUtil.sendPost("/sjhd/thyy", mapArr, function (res) {
            if (res.code == '0') {
                $("#ckthyyTextarea").val(res.data.hdnr);
            } else {
                layer.msg("没有获取到推送原因！");
                return false;
            }
        });
    }

    function activityRecordDiv(jcajxxuuid) {
        $("#activityRecordDiv").html("");
        var mapArr = {
            relevance: jcajxxuuid
        };

        CoreUtil.sendPost("/workflow/activity/record", mapArr, function (res) {
            if (res.code == '0') {
                var data = res.data;
                if (!CoreUtil.isEmpty(data)) {

                    var tmp = "<table class='layui-table'><tbody><tr>"
                        + "<td>序号</td>"
                        + "<td>处理时间</td>"
                        + "<td>状态</td>"
                        + "<td>处理人</td>"
                        + "<td>内容</td>"
                    for (var i in data) {
                        var content = "暂无";
                        if (!CoreUtil.isEmpty(data[i].content)) {
                            content = data[i].content;
                        }

                        tmp += "<tr><td>" + i + "</td>"
                            + "<td>" + data[i].createTime + "</td>"
                            + "<td>" + data[i].stateName + "</td>"
                            + "<td>" + data[i].currentMan + "</td>"
                            + "<td>" + content + "</td>"
                    }
                    tmp += "</tbody></table>";
                    $("#activityRecordDiv").html(tmp);
                } else {
                    $("#activityRecordDiv").html("暂无流程");
                }
            } else {
                // layer.msg(res.msg);
                return false;
            }
        });

    }

    //导出税务机关代码表
    function exportTaxorgcode() {
        CoreUtil.sendPost("/workflow/inspect/exportTaxorgcode", null, function (res) {
            console.log("res:", res.data)
            if (res.code == '0') {
                const data = res.data;
                if (!CoreUtil.isEmpty(data)) {
                    //全部导出
                    table.exportFile(jgdmTableIns.config.id, data, 'xls');
                } else {
                    layer.alert('未查询到需要导出的数据！', {icon: 2});
                }
            }
        });
        layer.close(index);
    }

    //导出代办页面数据
    $("#exportBtn").click(function () {
        layer.confirm('确定导出所有数据?', {icon: 3, title: '提示'}, function (index) {
            var map = {
                jcaybh: $("#jcaybh0").val(),
                nsrsbh: $("#nsrsbh0").val(),
                nsrmc: $("#nsrmc0").val(),
                zcajlx: "0",
                lasjq: $("#lrsjq0").val(),
                lasjz: $("#lrsjz0").val(),
            }
            CoreUtil.sendPost("/workflow/inspect/exportZcayxx", map, function (res) {
                if (res.code == '0') {
                    const data = res.data;
                    if (!CoreUtil.isEmpty(data)) {
                        //全部导出
                        table.exportFile(grdbTableIns.config.id, data, 'xls');
                        //导出时阻止页面刷新
                        $(".layui-form").submit(function (e) {
                            e.preventDefault();
                        })
                    } else {
                        layer.alert('未查询到需要导出的数据！', {icon: 2});
                    }
                }
            });
            layer.close(index);
        });
    });

    //导出已办页面数据
    $("#exportBtn1").click(function () {
        layer.confirm('确定导出所有数据?', {icon: 3, title: '提示'}, function (index) {
            var map = {
                jcaybh: $("#jcaybh1").val(),
                nsrsbh: $("#nsrsbh1").val(),
                nsrmc: $("#nsrmc1").val(),
                lasjq: $("#lrsjq1").val(),
                lasjz: $("#lrsjz1").val(),
                zcajlx: "1"
            }
            CoreUtil.sendPost("/workflow/inspect/exportZcayxx", map, function (res) {
                if (res.code == '0') {
                    const data = res.data;
                    if (!CoreUtil.isEmpty(data)) {
                        //全部导出
                        table.exportFile(grybTableIns.config.id, data, 'xls');
                        //导出时阻止页面刷新
                        $(".layui-form").submit(function (e) {
                            e.preventDefault();
                        })
                    } else {
                        layer.alert('未查询到需要导出的数据！', {icon: 2});
                    }
                }
            });
            layer.close(index);
        });
    });

    function grdbSearch() {
        grdbTableIns.reload({
            where: {},

            page: {
                curr: 1
            }
        });
    }

    function grybSearch() {
        grybTableIns.reload({
            where: {},

            page: {
                curr: 1
            }
        });
    }


    //立案时间起
    laydate.render({
        elem: '#startTime0'
        , type: 'date'
        , value: null
        , done: function (value) {
            if (value !== null && value !== undefined && value !== "") {
                startTime = value;
            } else {
                startTime = null;
            }
        }
    });
    //立案时间止
    laydate.render({
        elem: '#endTime0'
        , type: 'date'
        , value: null
        , done: function (value) {
            if (value !== null && value !== undefined && value !== "") {
                endTime = value;
            } else {
                endTime = null;
            }
        }
    });
    //立案时间止
    laydate.render({
        elem: '#startTime1'
        , type: 'date'
        , value: null
        , done: function (value) {
            if (value !== null && value !== undefined && value !== "") {
                endTime = value;
            } else {
                endTime = null;
            }
        }
    });
    //立案时间止
    laydate.render({
        elem: '#endTime1'
        , type: 'date'
        , value: null
        , done: function (value) {
            if (value !== null && value !== undefined && value !== "") {
                endTime = value;
            } else {
                endTime = null;
            }
        }
    });
    // 监听重置按钮
    $("#resetBtn0").click(function () {
        document.getElementById('searchForm0').reset(); // 原生重置表单
        form.render(); // 重新渲染 Layui 的动态组件
    })
    // 监听重置按钮
    $("#resetBtn1").click(function () {
        document.getElementById('searchForm1').reset(); // 原生重置表单
        form.render(); // 重新渲染 Layui 的动态组件
    })

</script>
</body>
</html>